package com.winter.Controller;

import com.winter.model.User;
import com.winter.service.ReplyService;
import com.winter.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;
import java.util.Map;

/**
 * Created by Administrator on 2017/8/16.
 */
@Controller
@RequestMapping(value = "/user")
public class UserController {

    @Autowired
    private UserService userService;
    @Autowired
    private ReplyService replyService;

    @ResponseBody
    @RequestMapping(value = "/add",
            produces = {"application/json;charset=UTF-8"})
    public int addUser(User user){
        return userService.addUser(user);
    }

    @RequestMapping(value = "/all/{pageNum}/{pageSize}", produces = {"application/json;charset=UTF-8"})
    public Object findAllUser(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize){

        return userService.findAllUser(pageNum,pageSize);
    }


    @RequestMapping(value = "/checkMoney/{id}/{money}", produces = {"application/json;charset=UTF-8"})
    public boolean findAllUser(@PathVariable("id") Long id, @PathVariable("money") BigDecimal money){

        return userService.checkMoneyById(id,money);
    }


    @RequestMapping(value = "/update", produces = {"application/json;charset=UTF-8"})
    public int updateByPrimaryKey(User user){

        return userService.updateByPrimaryKey(user);
    }

    //提问者撤销问题
    @ResponseBody
    @RequestMapping(value = "/cancelTopic", produces = {"application/json;charset=UTF-8"})
    public void cancelTopic(Map<String,Object> paramMap){

        userService.cancelTopic(paramMap);
    }

    //用户满意
    @ResponseBody
    @RequestMapping(value = "/responseAnswer", produces = {"application/json;charset=UTF-8"})
    public void responseAnswer(Map<String,Object> paramMap){

        replyService.responseAnswer(paramMap);
    }

    //用户不满意
    @ResponseBody
    @RequestMapping(value = "/unConfirm", produces = {"application/json;charset=UTF-8"})
    public void unConfirm(Map<String,Object> paramMap){

        replyService.unConfirm(paramMap);
    }
}